
#import "Card_Menu.h"
#import "Card_PlayerSelected.h"
#import "Card_Game.h"
#import "GameConfig.h"

@implementation Card_Menu

+(CCScene *) scene
{
	// 'scene' is an autorelease object.
	CCScene *scene = [CCScene node];
	
	// 'layer' is an autorelease object.
	Card_Menu *layer = [Card_Menu node];
	
	// add layer as a child to scene
	[scene addChild: layer];
	
	// return the scene
	return scene;
}

- (void) dealloc
{
	[super dealloc];
}

-(void)Card_Menu_Des:(id)sender
{
	if(delegate)
	{
		[delegate Card_MenuSelect:ECard_Menu_Des];
	}
}

-(void)Card_Menu_Return:(id)sender
{
	if(delegate)
	{
		[delegate Card_MenuSelect:ECard_Menu_Return];
	}
}

-(void)Card_Menu_Play:(id)sender
{
	if(delegate)
	{
		[delegate Card_MenuSelect:ECard_Menu_Play];
	}
}

-(id)init:(id<Card_MenuDelegate>) _delegate
{
	self = [super init];
	if (self)
	{
		delegate = _delegate;
		//CGSize s = [[CCDirector sharedDirector] winSize];
		
		//LOGO
		CCSprite *spLogo=[CCSprite spriteWithFile:@"logo.png"];
		spLogo.position = ccp(SCREEN_WIDTH/2,400);
		[self addChild:spLogo];

		//纸牌大小
		CCSprite *spCardTitle=[CCSprite spriteWithFile:@"card_title.png"];
		spCardTitle.position = ccp(SCREEN_WIDTH/2,240);
		[self addChild:spCardTitle];
		
		//底部背景
		/*
		CCSprite *bottomBg=[CCSprite spriteWithFile:@"bottom_bg.png"];
		bottomBg.position = ccp(SCREEN_WIDTH/2,BOTTOM_HEIGHT);
		[self addChild:bottomBg];
		*/
		
		//开始游戏
		//CCMenuItem *startMenu = [CCMenuItemFont itemFromString:@"开始游戏"	target:self selector:@selector(Card_Menu_Play:)];
		/*
		CCMenuItemImage *startMenu = [CCMenuItemImage itemFromNormalImage:@"start_game.png" selectedImage:nil target:self selector:@selector(Card_Menu_Play:)];
		CCMenu *mn = [CCMenu menuWithItems:startMenu,  nil];
		mn.position = ccp(SCREEN_WIDTH/2,BOTTOM_HEIGHT);
		
		[self addChild:mn z:1 tag:2];
		*/
		
		//返回
		
		CCMenuItemImage *vm = [CCMenuItemImage itemFromNormalImage:@"back_icon.png" selectedImage:nil target:self selector:@selector(Card_Menu_Return:)];	
		CCMenu *vmm = [CCMenu menuWithItems: vm, nil];
		vmm.position = ccp(BOTTOM_X, BOTTOM_HEIGHT);
		[self addChild:vmm z:2];
		
		
		//help
		/*
		CCMenuItemImage *help = [CCMenuItemImage itemFromNormalImage:@"help_icon.png" selectedImage:nil target:self selector:@selector(Card_Menu_Des:)];	
		CCMenu *helpMenu = [CCMenu menuWithItems: help, nil];
		helpMenu.position = ccp(SCREEN_WIDTH - BOTTOM_X , BOTTOM_HEIGHT);
		//helpMenu.contentSize = CGSizeMake(58, 46);
		[self addChild:helpMenu z:2];
		*/
		
		CCMenuItemImage *startMenu = [CCMenuItemImage itemFromNormalImage:@"bottle_start.png" selectedImage:nil target:self selector:@selector(Card_Menu_Play:)];
		CCMenu *startmn = [CCMenu menuWithItems:startMenu,  nil];
		startmn.position = ccp(SCREEN_WIDTH/2,108);
		[self addChild:startmn z:1 tag:2];
		
		CCMenuItemImage *desMenu = [CCMenuItemImage itemFromNormalImage:@"bottle_des.png" selectedImage:nil target:self selector:@selector(Card_Menu_Des:)];
		CCMenu *desmn = [CCMenu menuWithItems:desMenu,  nil];
		desmn.position = ccp(SCREEN_WIDTH/2,60);
		[self addChild:desmn z:1 tag:2];
		
	}
	
	return self;
}

-(void)textFieldDown:(id)sender
{
	[(UITextField*)sender resignFirstResponder]; //取消键盘
}

- (void)layerReplaced
{
	
}

@end
